package com.medicine.prm.controller;

import com.medicine.common.base.ResponseData;
import com.medicine.common.exception.WarnException;
import com.medicine.prm.entity.Appointment;
import com.medicine.prm.param.AppointmentParam;
import com.medicine.prm.service.AppointmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

@Api(description = "预约挂号")
@RestController
@RequestMapping("/appointment")
public class AppointmentController {

    @Autowired
    private AppointmentService appointmentService;


    @ApiOperation(value="预约挂号新增")
    @PostMapping
    public ResponseData addAppointment(@RequestBody Appointment appointment){
        appointmentService.addAppointment(appointment);
        return ResponseData.success("新增成功!");
    }

    @ApiOperation(value="预约挂号新增")
    @PostMapping("/add")
    public ResponseData addAppointments(@RequestBody AppointmentParam appointmentParam) throws ParseException, WarnException {
        appointmentService.installAppointment(appointmentParam);
        return ResponseData.success("新增成功!");
    }
}
